<?php

namespace App\Http\Requests\finance;

use App\Http\ValidateResult;
use Illuminate\Support\Facades\Validator;

trait ProfitTestRequest
{
    public static function add_check(array $params): ValidateResult {
        $validator = Validator::make($params, [
            'total_get' => 'required|array',
            'total_pay' => 'required|array',
            'profit_currency_id' => 'required',
        ], [
            'total_get.required' => '应收测算数据不能为空',
            'total_pay.required' => '应付测算数据不能为空',
            'profit_currency_id.required' => '毛利币种不能为空',
        ]);

        if ($validator->fails()) {
            return ValidateResult::error($validator->errors()->first());
        }
        return ValidateResult::correct();
    }

}
